$(document).ready(function() {
    $('.tooltip').tooltipster();
});

function mostrarOcultar(sevento, gst, cat, pos, EV) {
    $.ajax({
        type: 'post',
        dataType: 'json',
        url: 'Gestion/Gst2.php?nocache=' + Math.random(),
        data: {t: 4, sube: sevento, gst: gst, cat: cat, ev: EV},
        success: function(json) {

            if (json[0].respuesta > 0) {
                ievento = json[0].evn;
                if (gst == 0) {//mostrar
                    $("#celda0" + pos).empty().append("<img src='images/check.png' width='25' height='25' title='Visible en mi evento' />");
                    $("#celda1" + pos).empty().append("<a href='EditarEvento.php?evnt=" + ievento + "&ctg=" + cat + "' class='tooltip' title='Editar subevento' style='margin-right: 20px' >"
                            + "<img src='images/edit0.png' width='25' height='25' align='absbottom' />"
                            + "</a>"
                            + "<a href='SeccionesEvento.php?evnt=" + ievento + "&ctg=" + cat + "' class='tooltip' title='Editar secciones' style='margin-right: 20px' >"
                            + "<img src='images/sections.png' width='25' height='25' align='absbottom' />"
                            + "</a>"
                            + "<a onclick='mostrarOcultar(" + ievento + ",1," + cat + "," + pos + "," + EV + ")' class='tooltip' title='Ocultar subevento de mi evento'>"
                            + "<img src='images/book2_delete.png' width='25' height='25' align='absbottom' />"
                            + "</a>");

                } else {
                    $("#celda0" + pos).empty().append("<small style='color: #9C9C9C'> (Oculto) </small>");
                    $("#celda1" + pos).empty().append("<a onclick='mostrarOcultar(" + ievento + ",0," + cat + "," + pos + "," + EV + ")' class='tooltip' title='Mostrar subevento en mi evento'>"
                            + "<img class='imgClare' src='images/check.png' width='25' height='25' align='absbottom' />"
                            + "</a>");
                }

            } else {
                alert("Ha ocurrido un error, intente nuevamente. ");
                alert(json[0].q);
            }
        }
    });
}